package com.xiaochong.tir.api.controller;

import com.xiaochong.tir.api.service.TokenIndexRankService;
import com.xiaochong.tir.api.util.ApiVersion;
import com.xiaochong.tir.common.data.vo.*;
import com.xiaochong.tir.common.util.ApiResultCodeUtils;
import io.swagger.annotations.*;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * Created by org on 2018/4/25.
 */
@Api(value="通证指数")
@RestController
@RequestMapping(ApiVersion.API_V1_PREFIX+"/index")
public class TokenIndexRankController {

    @Autowired
    private TokenIndexRankService tokenIndexRankService;


    @ApiOperation(value = "TIR大盘指数", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；，x轴时间，y轴大盘指数")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "type", value = "是否第一次,传1代表第一次取所有数据，否则取最新的", required = true, dataType = "int", paramType = "query")
    )
    @PostMapping("/marketIndex")
    public ApiResultVo<ApiMarketIndexVo> getGrailIndex(@RequestParam(value = "type") int type){
        return tokenIndexRankService.getGrailIndex(type);
    }

    @ApiOperation(value = "TIR权重指数", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；，x轴时间，y轴权重指数")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "type", value = "是否第一次,传1代表第一次取所有数据，否则取最新的", required = true, dataType = "int", paramType = "query")
    )
    @PostMapping("/weightIndex")
    public ApiResultVo<ApiWeightIndexVo> getWeightIndex(@RequestParam(value = "type") int type){
        return tokenIndexRankService.getWeightIndex(type);
    }
    
    @ApiOperation(value = "TIR权重指数K线", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @ApiImplicitParams({
    		@ApiImplicitParam(name = "page", value = "当前页数", required = true, dataType = "String", paramType = "query"),
    		@ApiImplicitParam(name = "pagesize", value = "每页数量", required = true, dataType = "String", paramType = "query")
    })
    @PostMapping("/weightIndexKline")
    public ApiResultVo<ApiWeightIndexKlineVo> getWeightIndexKline(@RequestParam(value = "page") String page, @RequestParam(value = "pagesize") String pagesize){
        return tokenIndexRankService.getWeightIndexKline(page, pagesize);
    }
    
    @ApiOperation(value = "行业分类-指数", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；x轴时间，y轴行业指数和涨幅")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "是否第一次,传1代表第一次取所有数据，否则取最新的", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "industryId", value = "行业id从获取行业货币分类信息获取", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "industry", value = "行业名称", required = true, dataType = "String", paramType = "query")
    })
    @PostMapping("/allIndustryIndex")
    public ApiResultVo<ApiIndustryIndexVo> getAllIndustryIndex(@RequestParam(value = "type") Integer type,@RequestParam(value = "industryId") Integer industryId
            ,@RequestParam(value = "industry") String industry){
        return tokenIndexRankService.getAllIndustryIndex(type,industryId,industry);
    }
    @ApiOperation(value = "获取行业货币分类信息", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/industryTabInfo")
    public ApiResultVo<List<ApiIndustryTabInfoVo>> getIndustryTabInfo(){
        return tokenIndexRankService.getIndustryTabInfo();
    }
    @ApiOperation(value = "大盘强弱分析-赚钱效应", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/markMoneyEffect")
    public ApiResultVo<GraliIntensity> getMarkMoneyEffect(){
        return tokenIndexRankService.getMarkMoneyEffect();
    }

    @ApiOperation(value = "大盘强弱分析-量能变化", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/marketInterpretationChange")
    public ApiResultVo<ApiMarketInterpretationChange> getMarketInterpretationChange(){
        return tokenIndexRankService.getMarketInterpretationChange();
    }
    @ApiOperation(value = "大盘强弱分析-大盘强度", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/marketAnalysisTotalResult")
    public ApiResultVo<ApiMarketAnalysisTotalResult> getMarketAnalysisTotalResult(){
        return tokenIndexRankService.getMarketAnalysisTotalResult();
    }
    @ApiOperation(value = "大盘强弱分析-权重表现", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/marketWeightsPerformance")
    public ApiResultVo<ApiMarketWeightsPerformance> getMarketWeightsPerformance(){
        return tokenIndexRankService.getMarketWeightsPerformance();
    }

    @ApiOperation(value = "大盘K线数据", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/getBroaderKline")
    public ApiResultVo<List<ApiKlineBroader>> getBroaderKline(
            @RequestParam(value = "page") Integer page,
            @RequestParam(value = "size") Integer size){

        return tokenIndexRankService.getBroaderKline(page , size);
    }
  /*  @ApiOperation(value = "TIR行业指数", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "type", value = "是否第一次,传1代表第一次取所有数据，否则取最新的", required = true, dataType = "int", paramType = "query")
    )
    @GetMapping("/industryIndex")
    public ApiResultVo<List<List<ApiIndustryIndexVo>>> getIndustryIndex(@RequestParam(value = "type") int type){
        return tokenIndexRankService.getIndustryIndex(type);
    }*/

  /*  @ApiOperation(value = "概念币-概念币种列表", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/conceptSymbol")
    public ApiResultVo<List<ApiConceptSymbolVo>> getConceptSymbol(){
        //以下是假数据，用时会删除，去service获取
        ApiResultVo vo = new ApiResultVo();
        List<ApiConceptSymbolVo> list = new  LinkedList();
        ApiConceptSymbolVo voq = new ApiConceptSymbolVo();
        voq.setChange(3d);
        voq.setCirculatingSupply(34234d);
        voq.setMarketVolume(242342423d);
        voq.setPrice(23.3d);
        voq.setSymbol("币种");
        voq.setUrl("https:baidu.com");
        voq.setVolume24h(323d);
        for(int i=0;i<4;i++){
            list.add(voq);
        }
        vo.setCode(ApiResultCodeUtils.BASE_SUCCESS.getCode());
        vo.setMessage(ApiResultCodeUtils.BASE_SUCCESS.getMsg());
        vo.setDataStamp(423424L);
        vo.setData(list);
        return vo;
    }*/
  /*  @ApiOperation(value = "概念指数通用", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/conceptIndex")
    public ApiResultVo<List<ApiConceptIndexVo>> getConceptIndex(){
        //以下是假数据，用时会删除，去service获取
        ApiResultVo vo = new ApiResultVo();
        List<ApiConceptIndexVo> list = new  LinkedList();
        ApiConceptIndexVo voq = new ApiConceptIndexVo();
        voq.setChange(2323d);
        Date da = new Date();
        System.out.println(da.getTime());
        Timestamp t = new Timestamp(new Date().getTime());
        voq.setTimestamp(t);
        voq.setConceptIndex(2d);
        for(int i=0;i<4;i++){
            list.add(voq);
        }
        vo.setCode(ApiResultCodeUtils.BASE_SUCCESS.getCode());
        vo.setMessage(ApiResultCodeUtils.BASE_SUCCESS.getMsg());
        vo.setDataStamp(423424L);
        vo.setData(list);
        return vo;
    }*/
 /*   @ApiOperation(value = "底层技术及基础设施-指数", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/underTechnologyIndex")
    public ApiResultVo<List<ApiUnderTechnologyIndexVo>> getUnderTechnologyIndex(){
        //以下是假数据，用时会删除，去service获取
        ApiResultVo vo = new ApiResultVo();
        List<ApiUnderTechnologyIndexVo> list = new  LinkedList();
        ApiUnderTechnologyIndexVo voq = new ApiUnderTechnologyIndexVo();
        voq.setChange(2323d);
        Date da = new Date();
        System.out.println(da.getTime());
        Timestamp t = new Timestamp(new Date().getTime());
        voq.setTimestamp(t);
        voq.setUnderTechnology(2d);
        for(int i=0;i<4;i++){
            list.add(voq);
        }
        vo.setCode(ApiResultCodeUtils.BASE_SUCCESS.getCode());
        vo.setMessage(ApiResultCodeUtils.BASE_SUCCESS.getMsg());
        vo.setDataStamp(423424L);
        vo.setData(list);
        return vo;
    }
    @ApiOperation(value = "中间件和开发件技术-指数", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；")
    @GetMapping("/middlewareIndex")
    public ApiResultVo<List<ApiMiddlewareIndexVo>> getMiddlewareIndex(){
        //以下是假数据，用时会删除，去service获取
        ApiResultVo vo = new ApiResultVo();
        List<ApiMiddlewareIndexVo> list = new  LinkedList();
        ApiMiddlewareIndexVo voq = new ApiMiddlewareIndexVo();
        voq.setChange(2323d);
        Date da = new Date();
        System.out.println(da.getTime());
        Timestamp t = new Timestamp(new Date().getTime());
        voq.setTimestamp(t);
        voq.setMiddleware(2d);
        for(int i=0;i<4;i++){
            list.add(voq);
        }
        vo.setCode(ApiResultCodeUtils.BASE_SUCCESS.getCode());
        vo.setMessage(ApiResultCodeUtils.BASE_SUCCESS.getMsg());
        vo.setDataStamp(423424L);
        vo.setData(list);
        return vo;
    }*/

    @ApiOperation(value = "TIR大盘指数头部信息", notes = "返回code：1000-成功；5000-大盘查询失败")
    @GetMapping("/getBroaderIndexHeader")
    public ApiResultVo<ApiBroaderIndexHeaderVo> getBroaderIndexHeader(){
        return tokenIndexRankService.getBroaderIndexHeader();
    }
}
